ALTER PROCEDURE [dbo].[spe_sms_datato44_A00013]
	-- Add the parameters for the stored procedure here
AS
BEGIN
	declare @count int
	declare @sms_guid varchar(36)
	
	select @COUNT=COUNT(*) from ucis_data_to_44 where TYPE_ID='A00013'
	if @COUNT>0
	begin
		--获取催缴计划
		select top 1 @sms_guid=sms_guid from ucis_data_to_44 where TYPE_ID='A00013'
		if @sms_guid!=''
		begin
			begin	
				insert into OPENQUERY(UCIS115,'SELECT * from ucis.CJ_Comprehensive') select * from CJ_Comprehensive_UCIS where sms_guid=@sms_guid
			end
			begin	
				insert into OPENQUERY(UCIS115,'SELECT * from ucis.CJ_UpdateType')(GUID,TypeID,DBType,InTime) values(@sms_guid,'A00013',1,GETDATE())
				delete ucis_data_to_44 where TYPE_ID='A00013' and sms_guid=@sms_guid
			end
		end
	end
end